package com.tinysand.advert.entity.condition;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

/**
 * 推广单元地域限制实体类定义，只有请求满足对应的地域才会推广相应广告
 *
 * Created By TINY
 * Create Time 2020/2/15
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "ad_unit_district")
@EntityListeners(AuditingEntityListener.class) // 使用JPA审计自动维护日期
public class AdUnitDistrict {

    /* 推广单元地域限制表自增主键 */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

    /* 关联推广单元的主键 */
    @Column(name = "unit_id", nullable = false)
    private Long unitId;

    /* 省份限制 */
    @Column(name = "province", nullable = false)
    private String province;

    /* 城市限制 */
    @Column(name = "city", nullable = false)
    private String city;

    public AdUnitDistrict(Long unitId, String province, String city) {
        this.unitId = unitId;
        this.province = province;
        this.city = city;
    }
}
